package com.wangshuo.webadmin.common;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;

import javax.crypto.SecretKey;
import java.util.Date;

public class JWTUtil {
    private static long tokenExpiration=60*60*1000L;
    private static SecretKey tokensignKey= Keys.hmacShaKeyFor("M0PKKI6pYGVWWfDZw90a0lTpGYX1d4AQ".getBytes());
    public static String createToken(Long userId,String username){
        String token= Jwts.builder().setSubject("USER_INFO")
                .setExpiration(new Date(System.currentTimeMillis()+tokenExpiration)).claim("userId",userId).claim("username",username).signWith(tokensignKey).compact();
        return token;
    }
}
